package com.servlet;

import com.entity.Blog;
import com.service.BlogService;
import com.service.BlogServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "BlogServlet",urlPatterns = "/BlogServlet")
public class BlogServlet extends HttpServlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//1、获取请求参数

		//2、操作
		BlogService blogService = new BlogServiceImpl();
		List<Blog> list = blogService.findAll();

		//3、页面跳转
		request.setAttribute("blogList", list);
		request.getRequestDispatcher("list.jsp").forward(request, response);
	}
}
